
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>绑定银行卡</title>
    <link rel="stylesheet" href="../css/wzl-bootstrap.css?q=1111"/>
    <!--<script src="../js/dist/seajs/2.3.0/dist/sea.js"></script>-->
    <link rel="icon" href="../favicon.ico" type="image/x-icon" />
    <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
    <script>

        /*seajs.config({
            base:'../js/dist'
        })
        seajs.use('wzlh5/1.0.0/pay',function(pay){
            pay.pay('bindbank');
        })*/
    </script>
    <!-- 行内样式属于该页面独有样式 -->
    <style>
        /* 重新定制 ul样式 */
        .list-group{
            background: #fff;
            border-radius: 5px;
            border: 1px solid #dddddd;
        }
        .list-group-item{
            position: relative;
            display: block;
            margin: 0 0px;
            padding:8px 10px;
            background-color: #ffffff;
            border-top:none;
            border-left:none;
            border-right:none;
            border-bottom: 1px solid #f3f3f3;
        }
        /* 重新定制 form-control */
        .form-control{
            padding:6px 6px 6px 0;
        }

        .wzl-form-control{
            padding: 0 10px;
            margin-bottom: 20px;
        }
        .wzl-form-control-list{
            margin-top: 6px;
        }

        .ml20{margin-left: 5px; width: 100px;}

    </style>
</head>
<body>
<div id="warp">
    <div class="top-buff-bar"></div>
    <nav class="wzl-navbar navbar-default" role="navigation">
        <div class="container-fluid">
            <div class="navbar-header">
                <div class="wzl-nav-bar" onclick="history.back(-1)">
                    <span class="glyphicon glyphicon-wzl-back"></span>绑定银行卡
                </div>
            </div>
        </div>
    </nav>
    <div class="wzl-form-control">
        <select class="form-control pl10" name="ubank" id="bankname">

        </select>
    </div>    
    
    <div class="container">
        <form action="" role="form" class="">
            <ul class="list-group mb60" > 
            	 <li class="list-group-item clearfix">
                    <input type="text" class="form-control" name="userName" value="" placeholder="姓名不符将无法充值提现" id="uName"/>
                </li>

                <li class="list-group-item clearfix wzl-verifycode-block">
                  <input type="text" class="form-control bankCardNumber" name="username" value="" placeholder="银行卡号（必填）" id="bankcard"/>
                </li>                
            </ul>
        </form>

        <a href="javascript:;" onclick="addBankCard()" class="btn btn-wzl-default btn-lg btn-block wzl-mb-20" id="submit-btn"> 提交绑定</a>
       
    </div>
</div>
<!-- weinre 调试js -->
<!--
<script src="http://192.168.0.27:8081/target/target-script-min.js#anonymous" type="text/javascript">
</script>
-->
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script src="https://cdn.bootcss.com/layer/3.0.1/layer.min.js"></script>			
<script>
    var phoneNum;
	$(document).ready(function(){
		var paramStr = {};
		paramStr.phoneNum =localStorage.getItem("phoneNum");
		var params = {};
		params.paramStr = JSON.stringify(paramStr);
		Common.ajaxWithParamGet("/fenful/api/v1/common/getWechatBankList", params, function(data) {
			console.log(data);
       		var html="<option value='default'>请您点击选择银行</option>";
       		for(var i=0;i<data.length;i++){
       			var obj = data[i];
                html+="<option value='"+obj.bank_id+"'>"+obj.bank_name+"</option>";
       		}
       		$("#bankname").html(html);
		});
    });


    function addBankCard(){
        var reg2 = /^\d{16,19}$/;
        var reg = /^[0-9]*$/;
        phoneNum = Common.queryGetParam("phoneNum");
        if(!phoneNum){
            phoneNum = window.localStorage.getItem("phoneNum");
        }
        if(!phoneNum){
            layer.msg("获取用户手机号失败！");
            return;
        }
        //银行名
        var bankId = $("#bankname option:selected").val();
        if(bankId=='default'||!bankId){
            layer.msg("请选择银行！");
            return;
        }
        //姓名
        var realName = $('#uName').val();
        if(!realName){
            layer.msg("请填写您的真实姓名！");
            return;
        }
        //卡号
        var bankNum = $('#bankcard').val();
        if(!bankNum){
            layer.msg("请填写银行卡号！");
            return;
        }
        if(!reg2.test(bankNum)||!reg.test(bankNum)){
            layer.msg("银行卡号不合法！");
            return;
        }

        var paramStr = {};
        paramStr.bankId=bankId;
        paramStr.phoneNum=phoneNum;
        paramStr.bankNum=bankNum;
        paramStr.realName=realName;
        var params = {};
        params.paramStr = JSON.stringify(paramStr);
        Common.ajaxWithParamBack("/fenful/api/v1/common/addBank", params, function(re) {
            console.log(re);
            if(re.code=="200"){
                layer.msg("绑定成功！");
                window.location.href="myBank.html";
            }else{
                layer.msg("绑定失败："+re.message);
            }

        })

    }
</script>
</body>
</html>